package by.exposit.controller;

import by.exposit.domain.Comment;
import by.exposit.domain.Request;
import by.exposit.domain.User;
import by.exposit.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

@Controller
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    @RequestMapping(value =  "/new", method = RequestMethod.POST)
    public ModelAndView Comment( User user,Request request,Date postTime,String text){
        ModelAndView modelAndView = new ModelAndView();
        commentService.saveComment(new Comment(user, postTime, request,text));
        modelAndView.setViewName("welcome");
        return modelAndView;
    }

}
